package com.design.classroommanagement.teacher

import android.view.View
import com.design.classroommanagement.Pages
import com.design.classroommanagement.api.Role
import com.design.classroommanagement.databinding.ActivityTeacherMyBinding
import com.design.classroommanagement.manager.UserAccountManager
import com.laughing.lib.base.BaseFragmentNoVM
import com.laughing.lib.utils.clickWithTrigger
import com.laughing.lib.utils.finishAllActivities
import com.laughing.lib.utils.openPage
import kotlinx.android.synthetic.main.activity_admin_my.*
import kotlinx.android.synthetic.main.activity_teacher_my.*

class TeacherMyFragment : BaseFragmentNoVM<ActivityTeacherMyBinding>() {

    override fun initCompleted() {
        binding.apply {
            logoutRl.clickWithTrigger {
                UserAccountManager.logout()
                finishAllActivities()
            }


            pwdUpdateRl.clickWithTrigger {
                openPage(Pages.UpdatePasswordFragment)
            }

            infoRl.clickWithTrigger {
                openPage(Pages.TeacherPersonalFragment) {
                    withSerializable("user", UserAccountManager.user)
                }
            }

            courseLL.setOnClickListener(View.OnClickListener { //为了跳转到课程表界面，
                openPage(Pages.BookmarkListFragment)
            })
            classTabLL.setOnClickListener(View.OnClickListener { //为了跳转到课程表界面，
                openPage(Pages.BookmarkListFragment)
            })
            classroomLL.setOnClickListener(View.OnClickListener { //为了跳转到修改界面，
                openPage(Pages.TeacherClassroomFragment)
            })
            progressLL.setOnClickListener(View.OnClickListener { //为了跳转到添加课程进度界面，
                openPage(Pages.TeacherBookmarkProgressFragment)
            })
            rlTcollect.setOnClickListener(View.OnClickListener { //为了跳转到添加课程进度界面，
                openPage(Pages.TeacherBookmarkProgressFragment)
            })


            val user = UserAccountManager.user ?: return
            nameTv.text = user.name


        }
    }
}